package exception;

/**
 * @Author Justin Parker
 * @Date 2024/7/17 0017 16:05
 * @Version 1.0
 */
public class TryCatchDemo02 {
    public static void main(String[] args) {
        Integer a = null;
        int b = 0;
        int c = 0;
        try {
             int d = a.intValue(); //可能出现空指针异常
             c = a / b; //可能会出现算数异常
            //假如多个catch中异常处理逻辑相同，也可以采用如下方式进行合并
        } catch ( NullPointerException | ArithmeticException  e1){
            System.out.println("除数不能为0");
            c++;
        } finally {
            System.out.println("程序结束");
            c++;
        }
        System.out.println(c);
    }
}
